#include  <iostream>
using  namespace  std;
class Vector
{
public:
    Vector(int n=0):m_len(n)
    {
        if(n>0)
            m_pdata=new int[m_len];
        for(int i=0; i<m_len; i++)
            m_pdata[i]=5*i;
    }
    Vector& operator= (const Vector& other )
    {
        if( this== &other)
            return *this;
        else
        {
            delete[] m_pdata;
            m_len=other.m_len;
            m_pdata=new int[m_len];
            for(int i=0; i<m_len; i++)
                m_pdata[i]=other.m_pdata[i];
            return *this;
        }
    }
    void print()
    {
        cout<<"Vector length: "<<m_len<<"\nData are:";
        for(int i=0; i<m_len; i++)
            cout<<m_pdata[i]<<"\t";
        cout<<endl;
    }
    int& operator[](int iter)
    {
        if(iter>=0 && iter<m_len)
            return m_pdata[iter];
        else
        {
            cout<<"index out of range\n";
            exit(0);
        }

    }
private:
    int* m_pdata;
    int m_len;
};
int  main()
{
    Vector objA(4),objB;
    objA[2]=11;
    objB=objA;
    objB[1]=37;
    objA.print();
    objB.print();
    return  0;
}
